package com.icesoft.xsnow.framework.api.po;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.icesoft.xsnow.framework.api.valid.Update;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

/**
 * @program: xsnow
 * 自增主键父类
 * @author: xuefeng.gao
 * @create: 2019-05-15 15:16
 **/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class BaseEntity extends NormalEntity {
    private static final long serialVersionUID = 1L;

    @NotBlank(groups = {Update.class}, message = "id不允许为空")
    @TableId(type = IdType.AUTO)
    protected Integer id;

    /**
     * 0-正常，1-删除
     */
    @TableLogic
    private Integer del;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime createDate;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime updateDate;

    /**
     * 创建者ID
     */
    @TableField(fill = FieldFill.INSERT)
    private Integer createUid;
}
